function createRoute(data, routes = []) {
    for(let item of data) {
        if(item.children && item.children.length > 0) {
            createRoute(item.children, routes)
        } else {
            let route = {path: item.path}
            route.children = [{path: '', name: item.name, component: loadView(item.component)}]
            route.component = Layout
            routes.push(route)
        }
    }
    return routes
}

export const loadView = (view) => { // 路由懒加载
    return (resolve) =>  require([`@/views/${view}`], resolve)
}